﻿// JScript 文件

//动态创建可移动div
//移动div
var ie = (navigator.appVersion.indexOf("MSIE") != -1); //IE
var ff = (navigator.userAgent.indexOf("Firefox") != -1); //Firefox


 var mouseObj=null;
 var parentDiv=null;
 var pX;
 var pY;
 
 function divDown(evt,obj)
 {
     mouseObj = obj;
     if (mouseObj.setCapture)
     {
         mouseObj.setCapture();
     }
     else
     {
//         document.addEventListener("mousemove", move, true);
//         document.addEventListener("mouseup", up, true);

         window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);         
     }

     parentDiv = top.document.getElementById("pop");

     var event = window.event ? window.event : evt;
    
     pX = parseInt(parentDiv.style.left) - event.screenX
     pY = parseInt(parentDiv.style.top) - event.screenY;
 }

 function divMove(evt)
 {
     var event = window.event ? window.event : evt;
     if(mouseObj)
     {               
         parentDiv.style.left = pX + event.screenX + "px";
         parentDiv.style.top = pY + event.screenY + "px";                
     }
 } 
 
 function divUp()
 {
    if(mouseObj)
    {
        if (mouseObj.setCapture)
        {
            mouseObj.releaseCapture();
        }
        else
        {
//            document.removeEventListener("mousemove", move, true);
//            document.removeEventListener("mouseup", up, true);           

            window.releaseEvents(Event.MOUSEMOVE | Event.MOUSEUP);
        }
        mouseObj = null;  
        parentDiv = null;
    }
 }


//动态创建div
//title 标题
//ico 显示的图标，可为null
//url div里嵌入的iframe地址
//w宽度
//h高度
function ShowDivFrm(title,ico,url,w,h)
{
    var divPop = document.getElementById("pop");
    if(divPop == null)
    {        
        divPop = document.createElement("div");
        divPop.id = "pop";
        document.body.appendChild(divPop);    
    }
   
    divPop.style.display = "";
    
    var htmlStr ;
    
    
    if(url.toString().indexOf("?")>-1)
    {
        url += "&Title=" + title;
    }
    else
    {
        url += "?Title=" + title;
    }
    
    var top  = getDocHeight() / 2 - h / 2 + document.body.scrollTop;
    var left = document.body.clientWidth / 2 - w / 2 + document.body.scrollLeft;


    divPop.style.position = "absolute";
    divPop.style.left = left + "px";
    divPop.style.top = top + "px";
    divPop.style.zIndex = 50;
    divPop.style.width = w + "px";
    divPop.style.height = h + "px";
    //divPop.style.backgroundColor = "#ff0000";
    
    divPop.innerHTML = '<iframe id ="frm" src="' + url + '" width="100%" height="' + h + '" scrolling="no" frameborder="0" ></iframe>';   
    
        
  
    disableAll();


    // document.selection.empty();
    return false;
}

//设置高宽
//function Init(frame)
//{
//    frame = frame.contentWindow;
//    
//    var divfrm = document.getElementById("pop");
//    
//    if(divfrm == null)
//    {
//        return;
//    }
//    
//    var subDoc = frame.document;  
//    
//      
//    var height1 = subDoc.body.clientHeight;
//    var height2 = subDoc.documentElement.clientHeight;
//    
//    var height = (height1 > height2)?height1:height2;
//   
//    
//    var width = subDoc.body.scrollWidth;
////    if(subDoc.body.scroll.toLowerCase() == "yes")
////    {
////        width = width + 17;//滚动条的宽度
////    }
//    
// //   divfrm.style.height = height + "px";
////    divfrm.style.width = width + 10;
//     
//}

function delDivFrm()
{
    var targetObj = document.getElementById("pop");
    if (targetObj == null) 
	    alert("对象为空");
    else
    {
        targetObj.innerHTML = "";
        targetObj.style.display = "none";
        targetObj = null;	    
	}	 
	enableAll();
} 
//禁用页面所用元素
function disableAll()
{
    var divDisable = document.getElementById("divDisable");
   
    divDisable.style.left = "0px";
    divDisable.style.top = "0px";
    divDisable.style.width = document.body.clientWidth + "px";
    divDisable.style.height = getDocHeight() + "px";
        
    divDisable.style.display = "";   
    
}
//启用页面所有元素
function enableAll()
{
    var divDisable = document.getElementById("divDisable");
    divDisable.style.display = "none";
}

var btnRefresh; //用于刷新页面的按钮
//刷新页面的GridView
function refreshView(isContinue)
{    
    if(!isContinue)
    {
        enableAll();
    }
    btnRefresh.click();
}